package com.zzgc.modules.service.impl;

import com.zzgc.common.dao.StaticSchoolVisualizationDao;
import com.zzgc.common.entity.StaticSchoolVisualization;
import com.zzgc.modules.service.StaticSchoolVisualizationService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.List;

/**
 * (StaticSchoolVisualization)表服务实现类
 *
 * @author makejava
 * @since 2023-05-20 10:49:31
 */
@Service("staticSchoolVisualizationService")
public class StaticSchoolVisualizationServiceImpl implements StaticSchoolVisualizationService {
    @Resource
    private StaticSchoolVisualizationDao staticSchoolVisualizationDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public StaticSchoolVisualization queryById(Integer id) {
        return this.staticSchoolVisualizationDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param staticSchoolVisualization 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public List<StaticSchoolVisualization> queryByPage(StaticSchoolVisualization staticSchoolVisualization) {
        return this.staticSchoolVisualizationDao.queryAllByLimit(staticSchoolVisualization);
    }

    /**
     * 按条件，根据学校名字分组
     *
     * @param staticSchoolVisualization 查询条件
     * @return 对象列表
     */
    @Override
    public List<StaticSchoolVisualization> queryCountSum(StaticSchoolVisualization staticSchoolVisualization) {
        return this.staticSchoolVisualizationDao.queryCountSum(staticSchoolVisualization);
    }

    /**
     * 按条件，根据学校类型与年级分组
     *
     * @param staticSchoolVisualization 查询条件
     * @return 对象列表
     */
    @Override
    public List<StaticSchoolVisualization> queryTypeCountSum(StaticSchoolVisualization staticSchoolVisualization) {
        return this.staticSchoolVisualizationDao.queryTypeCountSum(staticSchoolVisualization);
    }

    /**
     * 新增数据
     *
     * @param staticSchoolVisualization 实例对象
     * @return 实例对象
     */
    @Override
    public StaticSchoolVisualization insert(StaticSchoolVisualization staticSchoolVisualization) {
        this.staticSchoolVisualizationDao.insert(staticSchoolVisualization);
        return staticSchoolVisualization;
    }

    /**
     * 修改数据
     *
     * @param staticSchoolVisualization 实例对象
     * @return 实例对象
     */
    @Override
    public StaticSchoolVisualization update(StaticSchoolVisualization staticSchoolVisualization) {
        this.staticSchoolVisualizationDao.update(staticSchoolVisualization);
        return this.queryById(staticSchoolVisualization.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.staticSchoolVisualizationDao.deleteById(id) > 0;
    }
}
